package com.xinzhidi.web.netty.controller;

import com.xinzhidi.common.core.controller.BaseController;
import com.xinzhidi.common.core.domain.AjaxResult;
import com.xinzhidi.web.netty.service.AgreementSeahorseValveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 户用阀门协议-（实时数据）Controller
 *
 * @author cx
 * @date 2023-06-13
 */
@RestController
@Api(tags = "海龙马调节阀协议-（实时数据）")
@RequestMapping("/agreementSeahorseValve")
public class AgreementSeahorseValveController extends BaseController {
    @Autowired
    private AgreementSeahorseValveService agreementSeahorseValveService;

    @ApiOperation("海龙马调节阀-【读阀门地址】指令下发")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dtuId", value = "dtuId", dataType = "long", dataTypeClass = Long.class)
    })
    @GetMapping("/readValveAddress")
    public AjaxResult readValveAddress(Long dtuId) {
        return toAjax(agreementSeahorseValveService.readValveAddress(dtuId));
    }

    @ApiOperation("海龙马调节阀-【写阀门地址】指令下发")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dtuId", value = "dtuId", dataType = "long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "oldAddress", value = "原地址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "newAddress", value = "现地址", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("/writeAddress")
    public AjaxResult writeAddress(Long dtuId, String oldAddress, String newAddress) {
        return toAjax(agreementSeahorseValveService.writeAddress(dtuId, oldAddress, newAddress));
    }

    @ApiOperation(value = "海龙马调节阀-【写目标调节值】指令下发", notes = "该接口只用于除远程控制阀门开度外的其他调节模式")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dtuId", value = "dtuId", dataType = "long", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "address", value = "地址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "model", value = "模式", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "value", value = "值", dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("/writeByModel")
    public AjaxResult writeByModel(Long dtuId, String address, String model, String value) {
        return toAjax(agreementSeahorseValveService.writeByModel(dtuId, address, model, value));
    }

}
